<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>添加用户</title>
<base href="<%=basePath%>">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="renderer" content="webkit|ie-comp|ie-stand">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,member-scalable=no" />
<meta http-equiv="Cache-Control" content="no-siteapp" />
<link href="static/admin/css/H-ui.min.css" rel="stylesheet" type="text/css" />
<link href="static/admin/css/H-ui.admin.css" rel="stylesheet" type="text/css" />
<link href="static/admin/lib/icheck/icheck.css" rel="stylesheet" type="text/css" />
<link href="static/admin/lib/Hui-iconfont/1.0.1/iconfont.css" rel="stylesheet" type="text/css" />
<link rel="stylesheet" type="text/css" href="static/admin/css/bootstrap.min.css" />
    <link rel="stylesheet" type="text/css" href="static/admin/css/admin-all.css" />
    <script type="text/javascript" src="static/admin/js/jquery-1.7.2.js"></script>
    <script type="text/javascript" src="static/admin/js/jquery-ui-1.8.22.custom.min.js"></script>
    <link rel="stylesheet" type="text/css" href="Styles/ui-lightness/jquery-ui-1.8.22.custom.css" />

</head>
<body>
 <div class="alert alert-info">当前位置<b class="tip"></b>用户列表<b class="tip"></b>用户添加</div>
<div class="pd-20">
  <form action="user/save.do" method="post"  class="form form-horizontal" id="" onsubmit="return validate();">
    <div class="row cl">
      <label class="form-label col-3"><span class="c-red">*</span>用户名：</label>
      <div class="formControls col-5">
         <!--bootstrap表单控制 class="input-text" -->
        <input type="text"  value="" placeholder="" id="username" name="USERNAME" datatype="*2-16" nullmsg="用户名不能为空">
      </div>
      <div class="col-4"> </div>
    </div>
    <div class="row cl">
      <label class="form-label col-3"><span class="c-red">*</span>密码：</label>
      <div class="formControls col-5">
        <input type="password"  value="" placeholder="" id="pwd1" name="PASSWORD" datatype="*2-16" nullmsg="密码不能为空"><span class="c-red">建议密码为6位以上的字母和数字组合</span>
      </div>
      <div class="col-4"> </div>
    </div>
     <div class="row cl">
      <label class="form-label col-3"><span class="c-red">*</span>确认密码：</label>
      <div class="formControls col-5">
        <input type="password" value="" placeholder="" id="pwd2" name="PASSWORD2" datatype="*2-16" nullmsg="密码不能为空">
      </div>
      <div class="col-4"> </div>
    </div>
      <div class="row cl">
      <label class="form-label col-3"><span class="c-red">*</span>角色：</label>
      <div class="formControls col-5">
        
        <input type="text" value="" placeholder="" id="content" name="CONTENT" datatype="*2-16" nullmsg="输入角色名：管理员/普通用户"><span class="c-red">角色类型：管理员/普通用户</span>
       <!--  <label id="content">角色类型：管理员/普通用户</label> -->
      </div>
      <div class="col-4"> </div>
    </div>
    <div class="row cl">
      <label class="form-label col-3"><span class="c-red">*</span>邮箱：</label>
      <div class="formControls col-5">
        <input type="text" value="" placeholder="" id="email" name="EMAIL" datatype="*2-16" nullmsg="邮箱不能为空"><span id="span2"></span>
      </div>
      <div class="col-4"> </div>
    </div>
    <div class="row cl">
      <label class="form-label col-3"><span class="c-red">*</span>联系方式：</label>
      <div class="formControls col-5">
        <input type="text" value="" placeholder="" id="phone" name="PHONE" datatype="*2-16" nullmsg="手机号码不能为空">
      </div>
      <div class="col-4"> </div>
    </div>
    <div class="row cl">
      <div class="col-9 col-offset-3">
        <input class="btn btn-primary radius" type="submit" value="&nbsp;&nbsp;提交&nbsp;&nbsp;">
       <a class="btn btn-danger" href="user/list.do">取消</a>
      </div>
    </div>
  </form>
</div>
</div>
<script type="text/javascript" src="static/admin/lib/jquery/1.9.1/jquery.min.js"></script> 
<script type="text/javascript" src="static/admin/lib/icheck/jquery.icheck.min.js"></script> 
<script type="text/javascript" src="static/admin/lib/Validform/5.3.2/Validform.min.js"></script>
<script type="text/javascript" src="static/admin/lib/layer/1.9.3/layer.js"></script>
<script type="text/javascript" src="static/admin/js/H-ui.js"></script> 
<script type="text/javascript" src="static/admin/js/H-ui.admin.js"></script>
<script type="text/javascript">
function validate(){
        var username = document.getElementById("username");
        var phone = document.getElementById("phone");
        var email = document.getElementById("email");
        var content = document.getElementById("content");
        var pwd1 = document.getElementById("pwd1");
        var pwd2 = document.getElementById("pwd2");
        if(trim(username.value)==null || trim(username.value)==""){
            alert("请输入用户名！");
            username.focus();
            return false;
        }
         if(trim(pwd1.value)==null || trim(pwd1.value)==""){
            alert("请输入密码！");
            pwd1.focus();
            return false;
        }
        if(trim(pwd2.value)==null || trim(pwd2.value)==""){
            alert("请再次输入密码！");
            pwd2.focus();
            return false;
        }
		if(pwd2.value != pwd1.value){
			alert("两次密码输入不一致！");
            pwd1.focus();
            return false;
		}
       	 if(trim(content.value)==null || trim(content.value)==""){
            alert("请输入角色！");
            content.focus();
            return false;
        }
       	if(trim(email.value)==null || trim(email.value)==""){
            alert("请输入邮箱！");
            email.focus();
            return false;
        }
        if(trim(email.value)!=null || trim(email.value)!=""){
        	checkEmail();
        	return true;
        }
        if(trim(phone.value)==null || trim(phone.value)==""){
            alert("请输入联系电话！");
            phone.focus();
            return false;
        }
       
        return true;
    }
    function trim(str){ //删除左右两端的空格
     return str.replace(/(^\s*)|(\s*$)/g, "");
    }
</script>
<script type="text/javascript">
function checkEmail(){  
        var email = $("#email").val();  
        email = $.trim(email);  
        var pattern = /^([a-zA-Z0-9]+[_|\_|\.]?)*[a-zA-Z0-9]+@([a-zA-Z0-9]+[_|\_|\.]?)*[a-zA-Z0-9]+\.[a-zA-Z]{2,3}$/;  
        if(email != null && email != ""){     
            if(!pattern.test(email)){  
                    $("#span2").html("<font color='red'>邮箱不合法，请重新输入！</font>");  
                    $("#email").focus();  
                    return false;  
            }  
        }else{  
            $("#span2").html("<font color='red'>邮箱不能为空！</font>");  
            $("#email").val("");  
            $("#email").focus();  
            return false;  
        }  
        $("#span2").html("<font color='green'>邮箱可用！</font>");  
    }  

</script>

</body>
</html>